package indi.h.mlx.core.bean;

import com.google.common.base.Optional;

import indi.h.mlx.custom.annotations.CColumn;
import indi.h.mlx.data.inter.DataModel;

public class Column {

	protected String fieldName;

	protected String[] parentName;

	protected CColumn cColumn;

	protected DataModel<Object, Object> dataInter;

	public Column() {

	}

	public Column(String fieldName, CColumn cColumn, DataModel<Object, Object> dataInter) {
		this.fieldName = fieldName;
		this.cColumn = cColumn;
		this.dataInter = dataInter;
	}

	public String completeFieldName() {
		StringBuilder sb = new StringBuilder();
		this.parentName = Optional.fromNullable(this.parentName).or(new String[] { "" });
		if (this.parentName[0].length() > 0) {
			sb.append(this.parentName[0]);
			sb.append(".");
		}
		sb.append(Optional.of(this.fieldName).get());
		return sb.toString();
	}

	public String getFieldName() {
		return fieldName;
	}

	public void setFieldName(String fieldName) {
		this.fieldName = fieldName;
	}

	public CColumn getcColumn() {
		return cColumn;
	}

	public void setcColumn(CColumn cColumn) {
		this.cColumn = cColumn;
	}

	public DataModel<Object, Object> getDataInter() {
		return dataInter;
	}

	public void setDataInter(DataModel<Object, Object> dataInter) {
		this.dataInter = dataInter;
	}

	public String[] getParentName() {
		return parentName;
	}

	public void setParentName(String[] parentName) {
		this.parentName = parentName;
	}

}
